package com.jxau.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jxau.dao.CommentDao;
import com.jxau.domain.Comment;
import com.jxau.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class CommentServiceImpl extends ServiceImpl<CommentDao, Comment> implements CommentService {

    @Resource
    private CommentDao commentDao;

    @Override
    public IPage<Comment> getPage(int currentPage, int pageSize, Comment comment) {
        QueryWrapper<Comment> qw = new QueryWrapper<>();
        if(comment.getCommentid() != null){
            qw.eq("commentid", comment.getCommentid());
        }
        if(comment.getMovieid() != null){
            qw.eq("movieid", comment.getMovieid());
        }
        IPage<Comment> page = new Page<>(currentPage, pageSize);
        commentDao.selectPage(page, qw);
        return page;
    }
}
